using System;
using Tarkin.InfrastructureLibrary.Core.Basic;
using Tarkin.InfrastructureLibrary.Tests.Core.Basic.TestUtilities.ConcreteClasses;
using NUnit.Framework;

namespace Tarkin.InfrastructureLibrary.Tests.Core.Basic
{
    /// <summary>
    /// ClassTests is the NUnit TestFixture for the Tarkin.InfrastructureLibrary.Core.Basic.Class class.
    /// </summary>
    [TestFixture]
    public class ClassTests
    {
        [Test]
        public void TestConstructorOneParameter ()
        {
            Class testClass = new Class ( "This is a Class" );

            Assert.IsNotNull ( testClass );
            Assert.AreEqual ( "This is a Class", testClass.Name );
        }

        [Test]
        public void TestConstructorTwoParameters ()
        {
            Class testClass = new Class ( true, "This is a Class" );

            Assert.IsNotNull ( testClass );
            Assert.AreEqual ( "This is a Class", testClass.Name );
            Assert.IsTrue ( testClass.IsAbstract );
        }

        [Test]
        public void TestSuperClassesProperty ()
        {
            Class superClass = new Class ( true, "This is a Superclass" );
            Class testClass = new Class ( true, "This is a Class" );

            testClass.SuperClasses.Add ( superClass );

            Assert.IsTrue ( testClass.SuperClasses.Contains ( superClass ) );
        }

        [Test]
        public void TestOwnedAttributesProperty ()
        {
            Class testClass = new Class ( true, "This is a Class" );
            Property property = new Property ( new ConcreteTypedElement ( "This is the TypedElement" ) );

            testClass.OwnedAttributes.Add ( property );

            Assert.AreEqual ( 1, testClass.OwnedAttributes.Count );
            Assert.IsTrue ( testClass.OwnedAttributes.Contains ( property ) );
        }

        [Test]
        public void TestOwnedOperationsProperty ()
        {
            Class testClass = new Class ( true, "This is a Class" );
            Operation operation = new Operation ( new ConcreteTypedElement ( "This is the TypedElement" ) );

            testClass.OwnedOperations.Add ( operation );

            Assert.AreEqual ( 1, testClass.OwnedOperations.Count );
            Assert.IsTrue ( testClass.OwnedOperations.Contains ( operation ) );
        }
    }
}
